<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>求某个字符出现的次数和位置</title>
		<script type="text/javascript">
			var arr = ['pink','red','pink','blue','red','pink']
			var count = 0;
			var index = arr.indexOf('pink');
			while(index != -1) {
				count++;
				console.log(index);
				//然后从这个元素的后一位去寻找
				index = arr.indexOf('pink',index + 1)
			}
			console.log('pink出现的次数:' + count)
		</script>
	</head>
	<body>
	</body>
</html>
